Imports System 
Imports System.Text 
Imports System.Data
Imports System.Data.SqlClient
Imports System.Data.Common
Imports System.Collections
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Configuration 
Imports System.Xml 
Imports System.Xml.Serialization
Imports SubSonic 
Imports SubSonic.Utilities
Namespace Data
	''' <summary>
	''' Strongly-typed collection for the MemberProfile class.
	''' </summary>
	<Serializable> _
	Public Partial Class MemberProfileCollection 
	Inherits ActiveList(Of MemberProfile, MemberProfileCollection)
	    Public Sub New()
		End Sub
	End Class
	''' <summary>
	''' This is an ActiveRecord class which wraps the MemberProfile table.
	''' </summary>
	<Serializable> _
	Public Partial Class MemberProfile 
	Inherits ActiveRecord(Of MemberProfile)
		#Region ".ctors and Default Settings"
		
		Public Sub New()
			SetSQLProps()
			InitSetDefaults()
			MarkNew()
		End Sub
		
		Public Sub New(ByVal useDatabaseDefaults As Boolean)
			SetSQLProps()
			If useDatabaseDefaults = True Then
				ForceDefaults()
			End If
			MarkNew()
		End Sub
		Public Sub New(ByVal keyID As Object)
			SetSQLProps()
			InitSetDefaults()
			LoadByKey(keyID)
		End Sub
		Public Sub New(ByVal columnName As String, ByVal columnValue As Object)
			SetSQLProps()
			InitSetDefaults()
			LoadByParam(columnName,columnValue)
		End Sub
		Private Sub InitSetDefaults()
			SetDefaults()
		End Sub
		
		Protected Shared Sub SetSQLProps()
			GetTableSchema()
		End Sub
		#End Region
		
		#Region "Schema and Query Accessor"
		
		Public Shared ReadOnly Property Schema() As TableSchema.Table
			Get
				If BaseSchema Is Nothing Then
					SetSQLProps()
				End If
				Return BaseSchema
			End Get
		End Property
		Private Shared Sub GetTableSchema()
			If (Not IsSchemaInitialized) Then
				'Schema declaration
				Dim schema As TableSchema.Table = New TableSchema.Table("MemberProfile", TableType.Table, DataService.GetInstance("ClubStarterKitData"))
				schema.Columns = New TableSchema.TableColumnCollection()
				schema.SchemaName = "dbo"
				'columns
				
                
                Dim colvarMemberid As TableSchema.TableColumn = New TableSchema.TableColumn(schema)
                colvarMemberid.ColumnName = "memberid"
                colvarMemberid.DataType = DbType.Guid
                colvarMemberid.MaxLength = 0
                colvarMemberid.AutoIncrement = false
                colvarMemberid.IsNullable = false
                colvarMemberid.IsPrimaryKey = true
                colvarMemberid.IsForeignKey = false
                colvarMemberid.IsReadOnly = false
                
                
                schema.Columns.Add(colvarMemberid)
                
                Dim colvarNewmsgthreshold As TableSchema.TableColumn = New TableSchema.TableColumn(schema)
                colvarNewmsgthreshold.ColumnName = "newmsgthreshold"
                colvarNewmsgthreshold.DataType = DbType.DateTime
                colvarNewmsgthreshold.MaxLength = 0
                colvarNewmsgthreshold.AutoIncrement = false
                colvarNewmsgthreshold.IsNullable = false
                colvarNewmsgthreshold.IsPrimaryKey = false
                colvarNewmsgthreshold.IsForeignKey = false
                colvarNewmsgthreshold.IsReadOnly = false
                
						colvarNewmsgthreshold.DefaultSetting = "('20000101')"
				
                
                schema.Columns.Add(colvarNewmsgthreshold)
                
                Dim colvarSignature As TableSchema.TableColumn = New TableSchema.TableColumn(schema)
                colvarSignature.ColumnName = "signature"
                colvarSignature.DataType = DbType.String
                colvarSignature.MaxLength = 1024
                colvarSignature.AutoIncrement = false
                colvarSignature.IsNullable = false
                colvarSignature.IsPrimaryKey = false
                colvarSignature.IsForeignKey = false
                colvarSignature.IsReadOnly = false
                
						colvarSignature.DefaultSetting = "('')"
				
                
                schema.Columns.Add(colvarSignature)
                
                Dim colvarBio As TableSchema.TableColumn = New TableSchema.TableColumn(schema)
                colvarBio.ColumnName = "bio"
                colvarBio.DataType = DbType.String
                colvarBio.MaxLength = 1024
                colvarBio.AutoIncrement = false
                colvarBio.IsNullable = false
                colvarBio.IsPrimaryKey = false
                colvarBio.IsForeignKey = false
                colvarBio.IsReadOnly = false
                
						colvarBio.DefaultSetting = "('')"
				
                
                schema.Columns.Add(colvarBio)
                
                Dim colvarSortdesc As TableSchema.TableColumn = New TableSchema.TableColumn(schema)
                colvarSortdesc.ColumnName = "sortdesc"
                colvarSortdesc.DataType = DbType.Boolean
                colvarSortdesc.MaxLength = 0
                colvarSortdesc.AutoIncrement = false
                colvarSortdesc.IsNullable = false
                colvarSortdesc.IsPrimaryKey = false
                colvarSortdesc.IsForeignKey = false
                colvarSortdesc.IsReadOnly = false
                
						colvarSortdesc.DefaultSetting = "((0))"
				
                
                schema.Columns.Add(colvarSortdesc)
                
                Dim colvarMsgsperpage As TableSchema.TableColumn = New TableSchema.TableColumn(schema)
                colvarMsgsperpage.ColumnName = "msgsperpage"
                colvarMsgsperpage.DataType = DbType.Int32
                colvarMsgsperpage.MaxLength = 0
                colvarMsgsperpage.AutoIncrement = false
                colvarMsgsperpage.IsNullable = false
                colvarMsgsperpage.IsPrimaryKey = false
                colvarMsgsperpage.IsForeignKey = false
                colvarMsgsperpage.IsReadOnly = false
                
						colvarMsgsperpage.DefaultSetting = "((10))"
				
                
                schema.Columns.Add(colvarMsgsperpage)
                
                Dim colvarShowavatars As TableSchema.TableColumn = New TableSchema.TableColumn(schema)
                colvarShowavatars.ColumnName = "showavatars"
                colvarShowavatars.DataType = DbType.Boolean
                colvarShowavatars.MaxLength = 0
                colvarShowavatars.AutoIncrement = false
                colvarShowavatars.IsNullable = false
                colvarShowavatars.IsPrimaryKey = false
                colvarShowavatars.IsForeignKey = false
                colvarShowavatars.IsReadOnly = false
                
						colvarShowavatars.DefaultSetting = "((1))"
				
                
                schema.Columns.Add(colvarShowavatars)
                
                Dim colvarShowsignatures As TableSchema.TableColumn = New TableSchema.TableColumn(schema)
                colvarShowsignatures.ColumnName = "showsignatures"
                colvarShowsignatures.DataType = DbType.Boolean
                colvarShowsignatures.MaxLength = 0
                colvarShowsignatures.AutoIncrement = false
                colvarShowsignatures.IsNullable = false
                colvarShowsignatures.IsPrimaryKey = false
                colvarShowsignatures.IsForeignKey = false
                colvarShowsignatures.IsReadOnly = false
                
						colvarShowsignatures.DefaultSetting = "((1))"
				
                
                schema.Columns.Add(colvarShowsignatures)
                
                Dim colvarSendwatchemails As TableSchema.TableColumn = New TableSchema.TableColumn(schema)
                colvarSendwatchemails.ColumnName = "sendwatchemails"
                colvarSendwatchemails.DataType = DbType.Boolean
                colvarSendwatchemails.MaxLength = 0
                colvarSendwatchemails.AutoIncrement = false
                colvarSendwatchemails.IsNullable = false
                colvarSendwatchemails.IsPrimaryKey = false
                colvarSendwatchemails.IsForeignKey = false
                colvarSendwatchemails.IsReadOnly = false
                
						colvarSendwatchemails.DefaultSetting = "((1))"
				
                
                schema.Columns.Add(colvarSendwatchemails)
                
                Dim colvarShowemail As TableSchema.TableColumn = New TableSchema.TableColumn(schema)
                colvarShowemail.ColumnName = "showemail"
                colvarShowemail.DataType = DbType.Boolean
                colvarShowemail.MaxLength = 0
                colvarShowemail.AutoIncrement = false
                colvarShowemail.IsNullable = false
                colvarShowemail.IsPrimaryKey = false
                colvarShowemail.IsForeignKey = false
                colvarShowemail.IsReadOnly = false
                
						colvarShowemail.DefaultSetting = "((0))"
				
                
                schema.Columns.Add(colvarShowemail)
                
				BaseSchema = schema
				
				'add this schema to the provider
                'so we can query it later
                DataService.Providers("ClubStarterKitData").AddSchema("MemberProfile",schema)
			End If
		End Sub
		Public Shared Function CreateQuery() As Query
			Return New Query(Schema)
		End Function
		
		#End Region
		
		#Region "Props"
	
          
        <XmlAttribute("Memberid")> _
        Public Property Memberid As Guid 
			Get
				Return GetColumnValue(Of Guid)("memberid")
			End Get
		    
			Set
				SetColumnValue("memberid", Value)
			End Set
		End Property
		
		
		  
        <XmlAttribute("Newmsgthreshold")> _
        Public Property Newmsgthreshold As DateTime 
			Get
				Return GetColumnValue(Of DateTime)("newmsgthreshold")
			End Get
		    
			Set
				SetColumnValue("newmsgthreshold", Value)
			End Set
		End Property
		
		
		  
        <XmlAttribute("Signature")> _
        Public Property Signature As String 
			Get
				Return GetColumnValue(Of String)("signature")
			End Get
		    
			Set
				SetColumnValue("signature", Value)
			End Set
		End Property
		
		
		  
        <XmlAttribute("Bio")> _
        Public Property Bio As String 
			Get
				Return GetColumnValue(Of String)("bio")
			End Get
		    
			Set
				SetColumnValue("bio", Value)
			End Set
		End Property
		
		
		  
        <XmlAttribute("Sortdesc")> _
        Public Property Sortdesc As Boolean 
			Get
				Return GetColumnValue(Of Boolean)("sortdesc")
			End Get
		    
			Set
				SetColumnValue("sortdesc", Value)
			End Set
		End Property
		
		
		  
        <XmlAttribute("Msgsperpage")> _
        Public Property Msgsperpage As Integer 
			Get
				Return GetColumnValue(Of Integer)("msgsperpage")
			End Get
		    
			Set
				SetColumnValue("msgsperpage", Value)
			End Set
		End Property
		
		
		  
        <XmlAttribute("Showavatars")> _
        Public Property Showavatars As Boolean 
			Get
				Return GetColumnValue(Of Boolean)("showavatars")
			End Get
		    
			Set
				SetColumnValue("showavatars", Value)
			End Set
		End Property
		
		
		  
        <XmlAttribute("Showsignatures")> _
        Public Property Showsignatures As Boolean 
			Get
				Return GetColumnValue(Of Boolean)("showsignatures")
			End Get
		    
			Set
				SetColumnValue("showsignatures", Value)
			End Set
		End Property
		
		
		  
        <XmlAttribute("Sendwatchemails")> _
        Public Property Sendwatchemails As Boolean 
			Get
				Return GetColumnValue(Of Boolean)("sendwatchemails")
			End Get
		    
			Set
				SetColumnValue("sendwatchemails", Value)
			End Set
		End Property
		
		
		  
        <XmlAttribute("Showemail")> _
        Public Property Showemail As Boolean 
			Get
				Return GetColumnValue(Of Boolean)("showemail")
			End Get
		    
			Set
				SetColumnValue("showemail", Value)
			End Set
		End Property
		
		
		
		
		#End Region
		
		
			    
	    
		
		
		
		
		
	    
	    'no foreign key tables defined (0)
	    
		
	    
	    'no ManyToMany tables defined (0)
	    
		
		#Region "ObjectDataSource support"
		
		''' <summary>
		''' Inserts a record, can be used with the Object Data Source
		''' </summary>
		Public Shared Sub Insert(ByVal varMemberid As Guid,ByVal varNewmsgthreshold As DateTime,ByVal varSignature As String,ByVal varBio As String,ByVal varSortdesc As Boolean,ByVal varMsgsperpage As Integer,ByVal varShowavatars As Boolean,ByVal varShowsignatures As Boolean,ByVal varSendwatchemails As Boolean,ByVal varShowemail As Boolean)
			Dim item As MemberProfile = New MemberProfile()
			
            item.Memberid = varMemberid
            
            item.Newmsgthreshold = varNewmsgthreshold
            
            item.Signature = varSignature
            
            item.Bio = varBio
            
            item.Sortdesc = varSortdesc
            
            item.Msgsperpage = varMsgsperpage
            
            item.Showavatars = varShowavatars
            
            item.Showsignatures = varShowsignatures
            
            item.Sendwatchemails = varSendwatchemails
            
            item.Showemail = varShowemail
            
			If Not System.Web.HttpContext.Current Is Nothing Then
				item.Save(System.Web.HttpContext.Current.User.Identity.Name)
			Else
				item.Save(System.Threading.Thread.CurrentPrincipal.Identity.Name)
			End If
		End Sub
		''' <summary>
		''' Updates a record, can be used with the Object Data Source
		''' </summary>
		Public Shared Sub Update(ByVal varMemberid As Guid,ByVal varNewmsgthreshold As DateTime,ByVal varSignature As String,ByVal varBio As String,ByVal varSortdesc As Boolean,ByVal varMsgsperpage As Integer,ByVal varShowavatars As Boolean,ByVal varShowsignatures As Boolean,ByVal varSendwatchemails As Boolean,ByVal varShowemail As Boolean)
			Dim item As MemberProfile = New MemberProfile()
		    
                item.Memberid = varMemberid
				
                item.Newmsgthreshold = varNewmsgthreshold
				
                item.Signature = varSignature
				
                item.Bio = varBio
				
                item.Sortdesc = varSortdesc
				
                item.Msgsperpage = varMsgsperpage
				
                item.Showavatars = varShowavatars
				
                item.Showsignatures = varShowsignatures
				
                item.Sendwatchemails = varSendwatchemails
				
                item.Showemail = varShowemail
				
			item.IsNew = False
			If Not System.Web.HttpContext.Current Is Nothing Then
				item.Save(System.Web.HttpContext.Current.User.Identity.Name)
			Else
				item.Save(System.Threading.Thread.CurrentPrincipal.Identity.Name)
			End If
		End Sub
		#End Region
		#Region "Columns Struct"
		Public Structure Columns
			Dim x as Integer
			
            Public Shared Memberid As String = "memberid"
            
            Public Shared Newmsgthreshold As String = "newmsgthreshold"
            
            Public Shared Signature As String = "signature"
            
            Public Shared Bio As String = "bio"
            
            Public Shared Sortdesc As String = "sortdesc"
            
            Public Shared Msgsperpage As String = "msgsperpage"
            
            Public Shared Showavatars As String = "showavatars"
            
            Public Shared Showsignatures As String = "showsignatures"
            
            Public Shared Sendwatchemails As String = "sendwatchemails"
            
            Public Shared Showemail As String = "showemail"
            
		End Structure
		#End Region
	End Class
End Namespace
